<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="vue.js"></script>
    <!-- 依赖于vue 所以导入这两个包有顺序 -->
    <script src="vue-resouce-1.3.4.js"></script>
</head>

<body>
    <div id="app">

        <input type="button" value="get" @click="getInfo">
        <input type="button" value="post" @click="postInfo">
    </div>
    <script>
        var vm = new Vue({
            el: '#app',
            data: {},
            methods: {
                getInfo() {
                    this.$http.get('url').then(result => {
                        console.log(result.body)
                    })
                },
                postInfo() {
                    //第二个 请求体参数
                    //第三个 如下设置表示 设置提交内容类型为 普通表单数据格式
                    this.$http.post('url', {}, {
                        emulateJSON: true
                    }).then(result => {
                        console.log(result.body)
                    })
                }
            }
        });
    </script>
</body>

</html>